home *** CD-ROM | disk | FTP | other *** search
- unit LockInfU;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Grids, DBGrids, Db, DBTables, ExtCtrls, DBCtrls;
-
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Table1: TTable;
- DataSource1: TDataSource;
- DBGrid1: TDBGrid;
- Button1: TButton;
- DBNavigator1: TDBNavigator;
- procedure Button1Click(Sender: TObject);
- procedure Table1AfterPost(DataSet: TDataSet);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- uses
- DbiProcs, DbiTypes, DbiErrs;
-
- procedure GetLockList(Tbl: TTable; LockList: TStrings);
- const
- Locks: array[0..9] of String = ('normal record write lock (write)',
- 'special Paradox record lock (read)',
- 'Paradox group lock', 'Paradox image lock',
- 'non-lock (table open & registered)', 'table read lock',
- 'table write lock', 'table exclusive lock',
- 'bogus (unknown) lock', 'unknown lock');
- var
- TmpCursor: HDbiCur;
- Lock: LOCKDesc;
- Res: DbiResult;
- begin
- Check(DbiOpenLockList(Tbl.Handle, True, True, TmpCursor));
- Check(DbiSetToBegin(TmpCursor));
- LockList.Clear;
- repeat
- Res:= DbiGetNextRecord(TmpCursor, dbiNoLock, @Lock, nil);
- if (Res <> DbiErr_Eof) then
- with Lock do
- LockList.Add(Format(
- '%s has a %s on %s (record %d, session %d, net session %d)',
- [szUserName, Locks[iType], Tbl.TableName, iRecNum, iSession, iNetSession]));
- until (Res <> DbiErr_None);
- Check(DbiCloseCursor(TmpCursor));
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- GetLockList(Table1, ListBox1.Items)
- end;
-
- procedure TForm1.Table1AfterPost(DataSet: TDataSet);
- begin
- DbiSaveChanges((DataSet as TTable).Handle)
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- {$ifdef Win32}
- DBNavigator1.Flat := True
- {$endif}
- end;
-
- end.
-